1. /* scistrm.cpp by K.Tsuru */
  2. // function ID = 903
  3. /**************************
  4. SComplex class
  5. It provides the input.
  6. **************************/
  7. #ifndef SN_H
  8. #include "sn.h"
  9. #endif
  10. static bool num_part(int c){
  11. if(isdigit(c)) return true;
  12. switch(c){
  13. case ' ':
  14. case 'e':
  15. case 'E':
  16. case '.':
  17. case '-':
  18. case '+': return true;
  19. default:break;
  20. }
  21. return false;
  22. }
  23. // set SComplex value by (rp,ip).() is not necessary Use delimiter ',' only.
  24. SComplex SetComplex(const char* s){
  25. string rp, ip;
  26. int i = 0, c;
  27. while( !num_part(s[i]) ) i++;
  28. while(num_part(c = s[i])){ rp += c; i++;}
  29. if(c == ',') i++;
  30. while(num_part(c = s[i])){ ip += c; i++;}
  31. return SComplex(rp.data(),ip.data());
  32. }
  33. istream& operator>>(istream& s, SComplex& a) { // added since version 2.21
  34. string buf;
  35. std::getline(s, buf);
  36. a = SetComplex(buf.data());
  37. return s;
  38. }

scistrm.cpp : last modifiled at 2015/05/06 16:17:04(891 bytes)
created at 2017/10/06 15:21:28
The creation time of this html file is 2017/10/06 15:27:09 (Fri Oct 06 15:27:09 2017).